program yueshefu
var
 a:array[1..100] of integer;
 n,m,i,j,p:integer;
begin
 write('input n,m:');
 read(n,m);
 for i:=1 to n do
   a[i]:=i;
 p:=1;
 for i:=1 to n do
  begin
   j:=0;
   while (j<m)do
    begin
     if(a[p]<>0)then j:=j+1;
     if(p=n)then p:=1 else p:=p+1
    end;
   if(p<>1) then
     begin 
      write(a[p-1],' ');
      a[p-1]:=0 
     end
   else
    begin
     write(a[n],' ');a[n]:=0 
    end
  end
end

